package com.bwhx.eruler.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bwhx.eruler.bean.Page;
import com.bwhx.eruler.bean.Pinlei;
import com.bwhx.eruler.service.PinleiService;
/**
 * @author Cuilitang
 *
 */
@Deprecated
@Controller
public class PinleiController extends BaseController {
	
	@Autowired
	PinleiService pinleiService;
	
	
	/*@ResponseBody
	@RequestMapping(value = "/page.savePinlei.ashx")
	public String saveOOrder(Pinlei pinlei,HttpSession session) {
		try{
			Staff staff = (Staff) session.getAttribute("staff");
			pinlei.setPpcreatetime(new Date());
			pinlei.setPpcreatorid(staff.getsId());
			
			pinleiService.insert(pinlei);
		
		}catch(Exception e){
			log.error(getTrace(e));
			return "fail";
		}
		
		
	    return "success";  
	  }*/
	
	@ResponseBody
	//@RequestMapping(value = "/page.pinleiList.ashx")
	 public Map<String,Object> orderList(Integer page,Integer rows,Pinlei pinlei) {
		
		
		//每页的开始记录
        int start = (page-1)*rows;
        Page p = new Page(start,rows,pinlei);
		Map<String,Object> resultMap = new HashMap<String,Object>();
		try{
			List<Pinlei> list = pinleiService.list(p);
			Integer count = pinleiService.count(pinlei);

					
			resultMap.put("total",count );//total键 存放总记录数，必须的  
			resultMap.put("rows",list);//rows键 存放每页记录 list 
			
		
			
		}catch(Exception e){
			log.error(getTrace(e));
			resultMap.put("msg", "失败！");
			resultMap.put("status", "0");
		}
		
	    return resultMap;  
	  }
	
	@ResponseBody
	//@RequestMapping(value = "/page.pinleidel.ashx")
	 public Map<String,String> OfflineOrderDel(@RequestParam String ppid){
		Map<String,String> resultMap = new HashMap<String, String>();
		
		pinleiService.del(ppid);
		resultMap.put("status", "1");
	    return resultMap;  
	  }
	

}
